Skip to content

feat(apply): persist planned deployment state (issue #15)#49

Merged
leo-aa88 merged 2 commits into
mainfrom
issue/15-apply-applier
Apr 11, 2026
Merged

feat(apply): persist planned deployment state (issue #15)#49
leo-aa88 merged 2 commits into
mainfrom
issue/15-apply-applier

Conversation

@leo-aa88
Copy link
Copy Markdown
Member

Summary

Implements local apply semantics from the design doc (§12.2 D, §16): persist desired deployment rows to SQLite, not remote deploy.

What changed

internal/apply

  • applier.go: Applier.ApplyPlan(ctx, env, graph, plan, at) runs all plan operations then updates applied_projects. Keeps RecordAppliedResource for direct upserts.
  • executor.go: For each operation—create/updateUpsertAppliedResource with spec_hash and normalized_spec_json; deleteDeleteAppliedResource; finally UpsertAppliedProject with project name and version.

internal/plan

  • Operation now carries SpecHash and NormalizedSpecJSON for create/update so apply does not re-derive material.
  • project_meta.go: ProjectDeploymentMeta(graph) returns project name and project resource spec_hash for applied_projects.version.

internal/state

  • DeploymentStore: new DeleteAppliedResource.
  • TransactionalDeployment: RunDeploymentTx(fn) for atomic apply.

internal/state/sqlite

  • deployment_ops.go: shared SQL helpers using a querier (*sql.DB / *sql.Tx).
  • deployment_tx.go: deploymentStoreTx + (*Store).RunDeploymentTx.
  • store.go: thin wrappers; idempotent delete (no error if row missing).

Tests

  • TestApplyPlan_thenListShowsResources: plan → apply → list/get shows project row and applied_projects row with non-empty version.
  • TestApplyPlan_deleteRemovesRow: apply full graph, then plan with agent removed → apply → agent GetAppliedResource returns sql.ErrNoRows.

Verification

  • make fmt (go fmt ./...)
  • make test (go test ./... -race)
  • make vet

Closes #15

Made with Cursor

Add Applier.ApplyPlan and executor to upsert/delete applied_resources
and upsert applied_projects using env and project spec_hash as version.

Extend plan.Operation with SpecHash and NormalizedSpecJSON; add
ProjectDeploymentMeta. DeploymentStore gains DeleteAppliedResource;
sqlite refactors deployment SQL into deployment_ops and implements
TransactionalDeployment via RunDeploymentTx.

Tests cover apply then list/get and delete removing rows (issue #15).

Made-with: Cursor
@leo-aa88 leo-aa88 merged commit 3ab4138 into main Apr 11, 2026
4 checks passed
@leo-aa88 leo-aa88 deleted the issue/15-apply-applier branch April 11, 2026 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MVP] Apply applier — persist planned deployment state (internal/apply)

1 participant